package com.example.administrator.coldlain.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.administrator.coldlain.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by Administrator on 2019/3/25 0025.
 */

public class Fragment2 extends Fragment {
    private ListView layout2list;
    List<HashMap<String, Object>> menulist;
    View view;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {

        view = inflater.inflate(R.layout.layout2, container, false);
        initmenu();
        return view;
    }


    private void initmenu() {
        layout2list = view.findViewById(R.id.layout2list);
        menulist = new ArrayList<>();
        HashMap<String, Object> hashMap;
        for (int i=0;i<=6;i++) {
            hashMap = new HashMap<>();
            hashMap.put("img", R.drawable.contacts_light);
            hashMap.put("name", "Name"+i);
            hashMap.put("title", "tilte"+i);
            menulist.add(hashMap);
        }

        SimpleAdapter simpleAdapter = new SimpleAdapter(getContext(), menulist,
                R.layout.user_item,
                new String[]{"img", "name","title"},
                new int[]{R.id.home_item_img, R.id.home_item_name,R.id.home_item_title});
        layout2list.setAdapter(simpleAdapter);

    }

}
